package com.gxa.meiye.admin.controller;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.gxa.meiye.admin.service.ScheduleService;
import com.gxa.meiye.core.common.JsonResult;
import com.gxa.meiye.core.pojo.domain.IncomeAndExpenditureinfo;
import com.gxa.meiye.core.pojo.domain.ScheduleInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@Api(tags = "日程和收入")
@RestController
@ResponseBody
@RequestMapping("/mlsschedule")
public class ScheduleController {
    @Autowired
    private ScheduleService scheduleService;
    @GetMapping("/getmyschedule")
    @ApiOperation(value = "查看日程,")
    public JsonResult getMySchedule() throws JsonProcessingException {
        List<ScheduleInfo> mySchedule = scheduleService.getMySchedule();
        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode("200");
        jsonResult.setMsg("查询成功");
        jsonResult.setData(mySchedule);
        if(StringUtils.isEmpty(mySchedule)){
            jsonResult.setMsg("没有对应的订单");
        }
        return jsonResult;
    }
    /**
     * 收入统计
     */
    @GetMapping("/getMyPay")
    @ApiOperation(value = "查询收入与支出")
    public JsonResult getMyPay() throws JsonProcessingException {
        JsonResult jsonResult = new JsonResult();
        List<IncomeAndExpenditureinfo> mymoney = scheduleService.getMymoney();
        jsonResult.setCode("200");
        jsonResult.setMsg("查询成功");
        if(mymoney==null){
            jsonResult.setMsg("没有收入信息");
        }
        jsonResult.setData(mymoney);
        return jsonResult;
    }
    @GetMapping("/getclearmoney")
    @ApiOperation(value = "查询详细收入")
    public JsonResult getClearmoney() throws JsonProcessingException {
        JsonResult jsonResult = new JsonResult();
        List<IncomeAndExpenditureinfo> clearmoney = scheduleService.getClearmoney();
        jsonResult.setCode("200");
        jsonResult.setMsg("查询成功");
        if(clearmoney==null){
            jsonResult.setMsg("没有收入信息");
        }
        jsonResult.setData(clearmoney);
        return jsonResult;
    }

}
